#include <stdio.h>
#include <string.h>
#include <stdint.h> // Add this line to include the necessary header file for uint8_t
#include <stdarg.h>

void NET_pub(int count, ...)
{
    va_list args;
    va_start(args, count);
    printf("AT+MPUB=\"$oc/devices/66752fa06bc31504f06fddf6_TESTCAR/sys/properties/report\",0,0,\"{\"services\": [{\"service_id\": \"CarService\",\"properties\": {");
    for (int i = 0; i < count; ++i)
    {
        const char *Key = va_arg(args, const char *);
        int Value = va_arg(args, int);
        printf("\"%s\": %d", Key, Value);
        if (i < count - 1)
        {
            printf(", ");
        }
    }

    printf("}}]}\"\r\n");

    va_end(args);
}

void NET_pubstr(int count, ...)
{
    va_list args;
    va_start(args, count);

    printf("AT+MPUB=\"$oc/devices/66752fa06bc31504f06fddf6_TESTCAR/sys/properties/report\",0,0,\"{\"services\": [{\"service_id\": \"CarService\",\"properties\": {");

    for (int i = 0; i < count; ++i)
    {
        const char *Key = va_arg(args, const char *);
        const char *Value = va_arg(args, const char *);
        printf("\"%s\": \"%s\"", Key, Value);
        if (i < count - 1)
        {
            printf(", ");
        }
    }

    printf("}}]}\"\r\n");

    va_end(args);
}
int main(void)
{
    NET_pubstr(1, "Door", "OFF");
    NET_pub(2, "GPS_N", 23049, "GPS_E", 11339);

    return 0;
}